var timeout = 5;
var id = 0;

function startRequest()
{
  url = "http://localhost/adv.php?id=" + id;
  startGETRequest(url, onComplete, onEnd);
}

function onEnd()
{
}

function onComplete(text, xml)
{
  arr = text.split("\n");
  if(arr.length == 3){
    var imgEl = document.getElementById("advImg");
    var linkEl = document.getElementById("advLink");
    imgEl.src = arr[0];
    linkEl.href = arr[1];
    id = arr[2];
  }
  setTimeout("startRequest();", timeout * 1000);
}